﻿using DAL;
using POCOS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace GUI.Models
{
    public class RenderImage
    {
        private AuteurContext db = new AuteurContext();
        public void UploadImageToDB(HttpPostedFileBase file)
        {
            Images img = new Images();
            img.Extension = file.ContentType;
            img.ImageName = file.FileName;
            img.ImageBytes = ConvertToBytes(file);


            db.Images.Add(img);
                db.SaveChanges();
           

        }

        private byte[] ConvertToBytes(HttpPostedFileBase Image)
        {
            byte[] imageBytes = null;
            BinaryReader reader = new BinaryReader(Image.InputStream);
            imageBytes = reader.ReadBytes((Int32)Image.ContentLength);
            return imageBytes;
        }



    }
}